<?php
namespace Admin\Controller;
use Admin\Controller\BaseController;
class CommentController extends BaseController{
	//添加评论
	public function add_post_json(){				
		$data['content']=$_POST['content'];
		$data['blogid']=$_POST['id'];
		$data['customerid']=$_SESSION['customer']['id'];
		$res=M('Comment')->add($data);
		if($res){
			$data=array(
				'error_no'=>10012,
				'msg'=>'评论成功',
				'res'=>$res;
				'status'=>1,
			);	
		}else{
			$data=array(
				'error_no'=>20012,
				'msg'=>'评论失败',
				'status'=>0,
			);
		}
		$this->Response($data,'json');
	}
	//评论列表
	public function list_json(){		
		$map['blogid']=$_GET['id'];
		$res=M('Comment')->where($map)->limit(10)->select();
		if($res){		
			$data=array(
				'error_no'=>10011,
				'msg'=>'评论列表',
				'res'=>$res,
				'status'=>1,
			);
		}else{
			$data=array(
				'error_no'=>20011,
				'msg'=>'暂无评论',
				'res'=>$res,
				'status'=>0,
			);


		}
		$this->Response($data,'json');

	}

	

}